home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Misc / Capture / Source / other.m < prev    next >
Text File  |  1995-06-12  |  651b  |  25 lines

  1. // You may freely copy, distribute and reuse the code in this example.
  2. // The author disclaims any warranty of any kind, expressed or implied,
  3. // as to its fitness for any particular use.
  4.  
  5. // Grab20 and Capture written by Peter Eisch.
  6.  
  7. #import "other.h"
  8.  
  9. void parsePath(char *path, char *dir, char *name)
  10.      /* Parse out the name and directory given a path */
  11. {
  12.     char *c1, *c2;
  13.     int dirlen, namelen;
  14.  
  15.     c1 = strrchr(path, '.');
  16.     c2 = strrchr(path, '/');
  17.     dirlen = (c2) ? c2-path+1 : 0;
  18.     namelen = ((c1) ? c1-path : strlen(path)) -dirlen;
  19.     strncpy(dir,path,dirlen);
  20.     dir[dirlen] = '\0';
  21.     strncpy(name, path+dirlen, namelen);
  22.     name[namelen] = '\0';
  23. }
  24.  
  25.